unit UPesquisaItensPedidovenda;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Grids, DBGrids;

type
  TFPesquisaItensPedidoVenda = class(TForm)
    DBGItens: TDBGrid;
    Label1: TLabel;
    BtnFechar: TBitBtn;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure BtnFecharClick(Sender: TObject);
    procedure DBGItensDblClick(Sender: TObject);
    procedure DBGItensDrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FPesquisaItensPedidoVenda: TFPesquisaItensPedidoVenda;

implementation

uses PedidoVenda_NOVO;

{$R *.dfm}

procedure TFPesquisaItensPedidoVenda.FormCreate(Sender: TObject);
begin

  Self.Constraints.MaxHeight := 340;
  Self.Constraints.MinHeight := 340;

  Self.Constraints.MaxWidth  := 689;
  Self.Constraints.MinWidth  := 689;

  
end;

procedure TFPesquisaItensPedidoVenda.FormShow(Sender: TObject);
begin
  DBGItens.DataSource := FPedidoVenda_NOVO.DSItens;
end;

procedure TFPesquisaItensPedidoVenda.BtnFecharClick(Sender: TObject);
begin
  close;
end;

procedure TFPesquisaItensPedidoVenda.DBGItensDblClick(Sender: TObject);
begin
  BtnFechar.Click;
end;

procedure TFPesquisaItensPedidoVenda.DBGItensDrawColumnCell(
  Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin
  {
  if DBGItens.DataSource.DataSet.FieldByName('PROD_TRAVAPEDIDO').AsString = 'T' then
  BEGIN

    DBGItens.Canvas.Brush.Color := clred;
    DBGItens.Canvas.Font.Color := clWhite;
    DBGItens.DefaultDrawDataCell(Rect, DBGItens.columns[datacol].field, State);
    Exit;

  end;
   }
  if (DBGItens.DataSource.DataSet.FieldByName('ITENSPED_VALORUNIT').AsFloat = 0.0) or
     (DBGItens.DataSource.DataSet.FieldByName('ITENSPED_VALORTOTAL').AsFloat = 0.0) then
  BEGIN

    DBGItens.Canvas.Brush.Color := clYellow;
    DBGItens.Canvas.Font.Color := clBlack;
    DBGItens.DefaultDrawDataCell(Rect, DBGItens.columns[datacol].field, State);
    Exit;

  end;


  DBGItens.Canvas.Brush.Color := clWhite;
  DBGItens.Canvas.Font.Color := clBlack;
  DBGItens.DefaultDrawDataCell(Rect, DBGItens.columns[datacol].field, State);

end;

end.
